package com.example.a05;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    Button btnLL, btnRL, btnCL, btnFL;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnLL = findViewById(R.id.btnLinearLayout);
        btnRL = findViewById(R.id.btnRelativeLayout);
        btnCL = findViewById(R.id.btnConstraintLayout);
        btnFL = findViewById(R.id.btnFrameLayout);

        btnLL.setOnClickListener(new mClick());
        btnRL.setOnClickListener(new mClick());
        btnCL.setOnClickListener(new mClick());
        btnFL.setOnClickListener(new mClick());
    }

    class mClick implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            if (view == btnLL) {
                // 通过信使intent对象，启动新的活动，将当前activity跳转到LinearLayout.class
                Intent intent = new Intent(MainActivity.this, LinearLayout.class);
                startActivity(intent);
            } else if (view == btnRL) {
                Intent intent = new Intent(MainActivity.this, RelativeLayout.class);
                startActivity(intent);
            } else if (view == btnCL) {
                Intent intent = new Intent(MainActivity.this, ConstraintLayout.class);
                startActivity(intent);
            } else if (view == btnFL) {
                Intent intent = new Intent(MainActivity.this, FrameLayout.class);
                startActivity(intent);
            }
        }
    }
}